/*
 * PushSender.h
 *
 *  Created on: 2013. 11. 15.
 *      Author: jjaehuny
 */

#ifndef PROJECTZ_NPROCESS_PUSHSENDER_H_
#define PROJECTZ_NPROCESS_PUSHSENDER_H_

#include "../NUtil/ThreadPool.h"

#include <string>
#include <vector>
#include <mutex>
#include <stack>

namespace ProjectZ { namespace NProcess {

class PushSender
{
public:
	struct Param {
		enum class Type {
			__NONE__,
			ANDROID,
			IOS,
		};

		Type				_eType;
		std::string		_sender;
		std::string 		_message;
		std::string		_uuid;

		void Initialize() {
			_eType = Type::__NONE__;
			_sender.clear();
			_message.clear();
			_uuid.clear();
		}

		void Finalize() {}
	};

public:
	PushSender();
	virtual ~PushSender();

public:
	//void 	Push(Param & param);
	void 	Push(Param * pParam);

	void	Flush();

private:
	void	work();
	void	work2();
	void	sendIOS(Param & param);
	void	sendAnd(Param & param);

private:


	std::vector<Param> 	_clsParamVectorPost;
	std::vector<Param *> 	_clsParamVectorPost2;
	std::deque<Param> 	_clsParamVector;
	std::deque<Param *> 	_clsParamVector2;

	NUtil::ThreadPool		_clsThreadPool;

	std::mutex 			_mutex;
};

} /*NProcess*/ } /*ProjectZ*/

#endif /* PROJECTZ_NPROCESS_PUSHSENDER_H_ */
